package com.aboverock.module.system.domain;

import com.aboverock.common.validator.NotContains;
import com.aboverock.core.orm.domain.StringBaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.aboverock.module.system.constant.SystemConstants;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
import javax.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.Length;

/**
 * <p>
 * 数据字典.
 * </p>
 *
 * @author Rock Wang
 * @since 2018-10-29
 */
@TableName("t_sys_dictionary")
@ApiModel(value = "Dictionary对象", description = "")
@JsonIgnoreProperties({ "createTime", "createUser", "updateTime", "updateUser" })
public class Dictionary extends StringBaseEntity {

    @ApiModelProperty(value = "唯一编码")
    @NotBlank
    @Length(min = 1, max = 64)
    @NotContains({ SystemConstants.DICTIONARY_PATH_CONNECTOR })
    private String code;

    @ApiModelProperty(value = "名称")
    @NotBlank
    private String name;

    @ApiModelProperty(value = "值")
    @Length(max = 1024)
    private String value;

    @ApiModelProperty(value = "备注")
    @Length(max = 64)
    private String remark;

    @ApiModelProperty(value = "字典类型为NULL，字典为字典类型ID")
    private String parentId;

    @ApiModelProperty(value = "字典路径")
    private String path;

    @ApiModelProperty(value = "排序")
    private Long orderNo;

    @ApiModelProperty(value = "0:可修改可删除，1：可修改不可删除，2，不可修改code且不可删除")
    private Integer limitOperation;

    @TableField(exist = false)
    private Set<Dictionary> children = new TreeSet<Dictionary>(
            Comparator.comparing(Dictionary::getOrderNo));

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Long getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(Long orderNo) {
        this.orderNo = orderNo;
    }

    public Integer getLimitOperation() {
        return limitOperation;
    }

    public void setLimitOperation(Integer limitOperation) {
        this.limitOperation = limitOperation;
    }

    public Set<Dictionary> getChildren() {
        return children;
    }

    public void setChildren(Set<Dictionary> children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return "Dictionary{" +
        "code=" + code +
        ", name=" + name +
        ", value=" + value +
        ", remark=" + remark +
        ", parentId=" + parentId +
        ", path=" + path +
        ", orderNo=" + orderNo +
        ", limitOperation=" + limitOperation +
        "}";
    }

}
